#include <QVBoxLayout>

#include "contentview.h"
#include "ui_contentview.h"
#include "cvlist.h"
#include "commentitemview.h"

ContentView::ContentView(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ContentView)
{
    ui->setupUi(this);
}

ContentView::~ContentView()
{
    delete ui;
}

void ContentView::setUserIcon(const QString &usericon)
{
    ui->userIcon->setImageUrl(usericon);
}

void ContentView::setTitle(const QString &title)
{
    ui->contentTitle->setText(title);
}

void ContentView::setDescription(const QString &desc)
{
    ui->contentDesc->setText(desc);
}

void ContentView::setOwner(const QString &owner)
{
    ui->contentOwner->setText(owner);
}

void ContentView::setComments(QList<Comment *> *comments)
{
    CVList *list = new CVList(false);
    int size = comments->size();
    for (int i = 0; i < size; ++i)
    {
        CommentItemView *commentItem = new CommentItemView(comments->at(i));
        ui->commentsBox->addWidget(commentItem);
        //list->appendItem(commentItem);
    }
    //list->addStretch();

    //QVBoxLayout *layout = new QVBoxLayout();
    //layout->addWidget(list);
    //ui->commentsBox->setLayout(layout);
}

void ContentView::setCommentCount(int count)
{
    //ui->commentsBox->setTitle(ui->commentsBox->title() + " - " + QString::number(count));
}
